export function getPath(e:any) {
    let domPath = Array();
    let domText = ""; //元素文本
    let path = "";
    if (e.innerText) {
        domText = e.innerText;
    } else {
        domText = e.nodeName.toLocaleLowerCase();
    }
    let domTime = "1111"; //点击时间
    //判断是否存在ID
    if (e.id) {
        domPath.unshift('#'+e.id.toLocaleLowerCase());
    } else {
        //循环匹配元素
        while (e.nodeName.toLowerCase() !== "html") {
            if(e.id){
                //判断是否存在ID
                domPath.unshift('#'+e.id.toLocaleLowerCase());
                break;
            }else if(e.tagName.toLocaleLowerCase() == "body") {
                //判断是否是BODY元素
                domPath.unshift(e.tagName.toLocaleLowerCase());
            }else{
                //遍历获取元素顺序
                for (let i = 0; i < e.parentNode.childElementCount; i++) {
                    if (e.parentNode.children[i] == e) {
                        let child = i == 0 ? '' : ':nth-child(' + (i + 1) + ')'
                        domPath.unshift(e.tagName.toLocaleLowerCase() + child);
                    }
                }
            }
            e = e.parentNode;
        }
        //domPath.unshift('html');
        path = domPath.toString().replaceAll(',', '>');
    }


    console.log('元素文本: ' + domText + '   路径: ' + domPath + '   时间: ' + domTime);

    //返回结果
    return {
        "text": domText,
        "path": path,
        "time": domTime
    };
}